Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 7, 2026

Description

Adds DOTNET_DbgCreateDumpToolPath environment variable to allow specifying a directory path where the createdump tool is located. In scenarios where createdump is not shipped with the NativeAOT runtime, users can now provide their own dump generation tool.

Note: This environment variable is only supported in NativeAOT applications and is ignored otherwise (not in other runtime configurations).

Implementation

  • Modified PalCreateDumpInitialize() to check DOTNET_DbgCreateDumpToolPath for a directory path
  • The runtime concatenates the directory path with "createdump" following the same pattern as the default behavior
  • No file validation during initialization (aligned with commit c507305 which removed stat checks)
  • Follows existing environment variable pattern using RhConfig::Environment::TryGetStringValue()
  • Uses safe string handling with proper null-termination and buffer management
  • Maintains backward compatibility: falls back to default behavior when not set

Usage

export DOTNET_DbgEnableMiniDump=1
export DOTNET_DbgCreateDumpToolPath=/path/to/directory
./myapp

The runtime will look for /path/to/directory/createdump

Customer Impact

Customers deploying NativeAOT in environments without createdump (custom distributions, minimal containers, embedded systems) currently cannot generate crash dumps. This prevents critical debugging in production scenarios.

Regression

No. This is a new opt-in feature with no impact on existing behavior. Only affects NativeAOT applications.

Testing

  • NativeAOT runtime build verification (clr.nativeaotruntime)
  • Code follows existing patterns for environment variable handling and memory management
  • Documentation updated with usage examples and NativeAOT-only clarification using "ignored otherwise" wording to avoid ambiguity since NativeAOT uses a stripped-down version of CoreCLR
  • Safe string handling verified

Risk

Low. New environment variable only used when explicitly set. Code path follows existing directory concatenation pattern used for default createdump lookup. No changes to existing dump generation logic. NativeAOT only, so no impact on other runtime configurations.

Original prompt

Using a new environment variable DOTNET_DbgCreateDumpToolPath, add the ability to override where we look for the createdump tool in the PalCreateDumpInitialize in PalCreateDump.cpp. In some scenarios we do not ship createdump and we should make it easier to 'bring your own' should one decide they need a dump.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @steveisok, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

Copilot AI and others added 3 commits January 10, 2026 19:26
… validation

- Changed DbgCreateDumpToolPath to accept a directory path instead of full executable path
- The runtime now concatenates the directory with "createdump" like the default behavior
- Removed stat() validation as it was removed in commit c507305
- Updated documentation to clarify this is NativeAOT only and the variable accepts a directory path
- Updated usage example to reflect the directory path usage

Co-authored-by: steveisok <[email protected]>
- Initialize buffer with '\0' before using strncat
- Use proper buffer size calculations in strncat calls to prevent buffer overruns
- Ensures safe string concatenation following C string best practices

Co-authored-by: steveisok <[email protected]>
- Calculate exact buffer size based on whether slash is needed
- Follow same pattern as default code path using strncpy and strncat
- More readable and maintainable code structure

Co-authored-by: steveisok <[email protected]>
Copilot AI changed the title Add DOTNET_DbgCreateDumpToolPath to override createdump location Add DOTNET_DbgCreateDumpToolPath to override createdump directory (NativeAOT only) Jan 10, 2026
Changed "ignored in CoreCLR" to "ignored otherwise" since NativeAOT uses a stripped-down version of CoreCLR, making the original wording ambiguous.

Co-authored-by: steveisok <[email protected]>
Copilot AI review requested due to automatic review settings January 12, 2026 21:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds a new environment variable DOTNET_DbgCreateDumpToolPath to allow NativeAOT applications to specify a custom directory where the createdump tool is located. This addresses scenarios where createdump is not shipped with the NativeAOT runtime, enabling users to provide their own dump generation tool.

Changes:

  • Modified PalCreateDumpInitialize() to check for DOTNET_DbgCreateDumpToolPath environment variable and use it to locate createdump
  • Added if/else logic to support both custom path and default library-based path discovery
  • Updated documentation to describe the new environment variable and its NativeAOT-only support

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/coreclr/nativeaot/Runtime/unix/PalCreateDump.cpp Adds environment variable check and custom path handling for createdump tool location with proper memory management and path concatenation logic
docs/design/coreclr/botr/xplat-minidump-generation.md Documents the new DOTNET_DbgCreateDumpToolPath environment variable with usage examples and NativeAOT-only clarification

jkotas added a commit that referenced this pull request Jan 14, 2026
… conditions (#123074)

Fixes potential crashes or hangs during process shutdown due to race
conditions in vector destructor execution.

Noticed while reviewing #122989

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: Jan Kotas <[email protected]>
Co-authored-by: Copilot <[email protected]>
steveisok added a commit to steveisok/docs that referenced this pull request Jan 14, 2026
Documents new environment variable added in dotnet/runtime#122989 where you can point to an alternate directory where the createdump tool lives. Works only with NativeAOT .NET 11 and above.
@steveisok steveisok merged commit dcbf341 into main Jan 14, 2026
101 checks passed
@steveisok steveisok deleted the copilot/add-dotnet-dbgcreatdumptoolpath branch January 14, 2026 16:44
steveisok added a commit to dotnet/docs that referenced this pull request Jan 14, 2026
* Add DOTNET_DbgCreateDumpToolPath env variable and description

Documents new environment variable added in dotnet/runtime#122989 where you can point to an alternate directory where the createdump tool lives. Works only with NativeAOT .NET 11 and above.

* Update docs/core/diagnostics/collect-dumps-crash.md

Co-authored-by: Genevieve Warren <[email protected]>

---------

Co-authored-by: Genevieve Warren <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants